package demoLinkedList;

import java.util.Stack;

class Solution {
    public int evalRPN(String[] tokens) {
        Stack<Integer> stack=new Stack<>();
        for (int i = 0; i < tokens.length; i++) {
            String tmp=tokens[i];
            if(!isOperation(tmp)){
                stack.push(Integer.parseInt(tmp));
            }else{
                Integer val2=stack.pop();
                Integer val1=stack.pop();

                switch (tmp){
                    case "+":stack.push(val1+val2);
                        break;
                    case"-":stack.push(val1-val2);
                        break;
                    case"*":stack.push(val1*val2);
                        break;
                    case"/":stack.push(val1/val2);
                        break;

                }
            }

        }
        return stack.pop();

    }
    public boolean isOperation(String str){
        if(str.equals("+")||str.equals("-")||str.equals("*")||str.equals("/")) {
            return true;
        }else{
            return false;
        }

    }
}
public class Test {
    public static void main(String[] args) {
        Stack<Integer> stack=new Stack<>();

    }
    public static void main1(String[] args) {
        MyLinkedList myLinkedList =new MyLinkedList();
        myLinkedList.addFirst(1);
        myLinkedList.addFirst(2);
        myLinkedList.addFirst(3);
        myLinkedList.addFirst(4);
        myLinkedList.display();
        myLinkedList.addIndex(2,6);
        myLinkedList.display();

    }
}
